﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class ProductionTechnologiesMapping : IEntityTypeConfiguration<ProductionTechnologies>
    {
        public void Configure(EntityTypeBuilder<ProductionTechnologies> builder)
        {
            builder.ToTable("ProductionTechnologies");
            builder.HasKey(pt => pt.ProductionTechnologyId);
            builder.Property(pt => pt.ProductionTechnologyId)
                .HasComment("工艺主键，自动编号");

            builder.Property(pt => pt.ProductionTechnologyCode)
                .IsRequired()
                .HasColumnType("varchar(20)")
                .HasComment("工艺编号，不能重复");

            builder.Property(pt => pt.ProductionTechnologyName)
                .IsRequired()
                .HasColumnType("varchar(30)")
                .HasComment("工艺名称，不能重复");

            builder.Property(pt => pt.GenerationDate)
                .IsRequired()
                .HasColumnType("datetime")
                .HasComment("生成日期");

            builder.Property(pt => pt.ProductId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("产品信息，外键（Products）");

            builder.Property(pt => pt.MaterialId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("物料信息，外键（Materials）");

            builder.Property(pt => pt.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(pt => pt.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(pt => pt.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(pt => pt.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(pt => pt.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
